{% extends 'base.html' %}

{% load pp_url %}
{% load topictags %}
{% load issuetags %}
{% load consensustags %}

{% block title %}
{% if request.object %}{{ request.object.text }}{% endif %} Issues
{% endblock title %}
{% block css %}
<link rel="stylesheet" type="text/css" href="/static/issues.css" />
{% endblock %}

{% block content %}

<div class = "topicdisplay">
{% pp_get_topic_list topic=request.object %}
    {% for topic in pp_topic.topic_list %}

        <a href="{% pp_url template="issues.html" object=topic %}">{{ topic.text }}</a>

    {% endfor %}
</div>
{% endpp_get_topic_list %}

   <hr />

{% pp_get_issue_list dimension="cont" topic=request.object %}

<div id ="issueList">
    <h2>Issues</h2>
    {% for issue in pp_issue.issue_list %}

        {% pp_consensus_get object=issue.id user=request.user %}
        <div class = "issue">
            <span class="name">{{issue.name|title}}:{{issue.interest}}</span>
            <div class = "voting">

                <span id="upvote{{issue.id}}">
                    <img src= "{{pp_consensus.upvoteimg}}" id="upvoteimg{{issue.id}}" onclick="upvote({{issue.id}},'upcount{{issue.id}}','upvoteimg{{issue.id}}');"/>
                </span> 
                    (<span id="upcount{{issue.id}}">{{pp_consensus.upvotes}}</span>)<br />
                <span id="neutralvote">
                    <img src= "{{pp_consensus.neutvoteimg}}" id="neutvoteimg{{issue.id}}" onclick="neutvote({{issue.id}},'neutcount{{issue.id}}','neutvoteimg{{issue.id}}');" />
                </span> 
                    (<span id="neutcount{{issue.id}}">{{pp_consensus.neutvotes}}</span>)<br />
                <span id="downvote">
                    <img src= "{{pp_consensus.downvoteimg}}" id="downvoteimg{{issue.id}}"  onclick="downvote({{issue.id}},'downcount{{issue.id}}', 'downvoteimg{{issue.id}}');" />
                </span> 
                    (<span id="downcount{{issue.id}}">{{pp_consensus.downvotes}}</span>)

            </div>
            <div class = "details">
                <div class="text">{{issue.text}}</div>
                <span class="topic">Categorized under <a href="/categories/{{issue.topic}}">{{issue.topic}}</a></span>
                <span class="detailLink"><a href="{% pp_url template="issue_detail.html" object=issue %}">More details</a></span>
            </div>
        </div>
    {% endpp_consensus_get %}
	{% empty %}
		There are no issues at this time, dude.

</div>


    {% endfor %}


{% endpp_get_issue_list %}

{% pp_issue_form POST=request.POST path=request.path topic=request.object %}
   <div id = "add">
   <hr />
   <h2>Create an issue</h2>
   {{ pp_issue.form.errors }}
	<form method="post" action="">
        Hey: {{ pp_issue.form.user }} <br>
		Speak your Mind: <br/>{{ pp_issue.form.text }}<br/>
	  	{{ pp_issue.form.form_id}}
		{% csrf_token %}
      <input type="submit" value="Submit">
	</form>
	</div>
{% endpp_issue_form %}



{% endblock content %}
